/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import model.Compromisso;
import model.CompromissoDAO;

/**
 *
 * @author Eduarda
 */
public class TrataTotalAniversariante extends Comando{

    @Override
    public void executar(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException, IOException, ServletException {
        String n;
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try{
         response.setContentType("text/html");
         String data1 = request.getParameter("data1");
         Compromisso compromisso = new Compromisso(null, null, data1, null, null, null, null,null,null);
        
         CompromissoDAO ddao = new CompromissoDAO();
         n = ddao.FunctionTotalAniversariantes(compromisso);
        
        HttpSession session = request.getSession(true);
        session.setAttribute("TotalAniversariantes", n);
       response.sendRedirect("relatorioMostraAniversariantes.jsp");
        } catch (IOException ioex) {
            throw new ServletException(ioex);
        } catch(SQLException sqlex){
              throw new ServletException (sqlex);
        }
        
    }
    
}
